import Mock from 'mockjs2'
import { builder } from '../util'

const nurseList = []
const manageList = []

for (let i = 0; i < 10; i++) {
  const manage = {
    name: Mock.mock('@cname'),
    avatar: '/user.svg',
    description: Mock.mock('@cparagraph(1,2)'),
    owner: Mock.mock('@cname'),
    startAt: Mock.mock('@datetime(2020-MM-dd HH:mm:ss)'),
    progress: {
      value: Mock.mock('@integer(0,100)')
    }
  }
  manageList.push(manage)
}

for (let i = 0; i < 10; i++) {
  const nurse = {
    id: Mock.mock('@increment'),
    name: Mock.mock('@cname'),
    age: Mock.mock('@integer(30,75)'),
    gender: Mock.mock('@integer(0,1)'),
    carType: Mock.mock('@integer(0,2)'),
    carId: Mock.mock('@integer(110000000000000000,990000000000000000)'),
    phone: Mock.mock('@integer(13000000000,18000000000)'),
    department: Mock.mock('@integer(0,5)'),
    level: Mock.mock('@integer(0,3)')
  }
  nurseList.push(nurse)
}

const nurses = () => {
  console.log('nurses', nurseList)
  return builder(nurseList)
}

const del = (id) => {
  delete nurseList[id - 1]
  return builder()
}

const management = () => {
  return builder(manageList)
}

Mock.mock(/\/nurse\/get/, 'get', nurses)
Mock.mock(/\/nurse\/del/, 'post', del)
Mock.mock(/\/nurse\/manage/, 'get', management)
